Python Graphics by B.J. Korites

Python Graphics by B.J. Korites

Author:B.J. Korites
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


5.3 Line Intersecting a Circle

The determination of whether the hit point of a line intersecting the plane of a circle is within the circle is trivial. As shown in Figure 5-13, if the distance from the circle’s center to the hit point is greater than the circle’s radius, it lies outside the circle:

if rh > r NO HIT

Figure 5-13Model for out-of-bounds test for a circle

We won’t bother writing a separate program to demonstrate this. You should be able to do that yourself by modifying Listing 5-1 or Listing 5-3. Simply fill the x[ ],y[ ], and z[ ] lists with the points defining the circle’s perimeter and the line coordinates and modify the functions plotsystem and hitpoint.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.